/**
 * Copyright(C) 2012 Luvina
 * MstJapanLogicImpl.java, 05-06-2012 NguyenVietDung
 */
package net.luvina.manageuser.logic.impl;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.sun.org.apache.bcel.internal.generic.LSTORE;

import net.luvina.manageuser.dao.MstJapanDao;
import net.luvina.manageuser.dao.impl.GenericDaoImpl;
import net.luvina.manageuser.hibernate.MstJapan;
import net.luvina.manageuser.logic.MstJapanLogic;

/**
 * MstJapanLogicImpl: Implement MstJapanLogic để Xử lý logic cho các chức năng
 * liên quan đến mst_japan
 *
 * @author NguyenVietDung
 *
 */
@Service("mstJapanLogic")
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = { Throwable.class })
public class MstJapanLogicImpl implements MstJapanLogic {
	@Autowired
	private MstJapanDao mstJapanDao;

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * net.luvina.manageuser.logic.MstJapanLogic#existMstJapan(java.lang.String)
	 */
	@Override
	public boolean existMstJapan(String codeLevel) {
		boolean isExist = this.mstJapanDao.existMstJapan(codeLevel);
		if (!isExist) {
			return false;
		}
		return true;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * net.luvina.manageuser.logic.MstJapanLogic#getListItemJapan(java.lang.
	 * String)
	 */
	@Override
	public List<SelectItem> getListItemJapan(String title) {
		List<MstJapan> lsMstJapan = this.mstJapanDao.getListJapan();
		List<SelectItem> lsItemMstJapan = new ArrayList<SelectItem>();
		lsItemMstJapan.add(new SelectItem("", title));
		for (MstJapan item : lsMstJapan) {
			lsItemMstJapan.add(new SelectItem(item.getCodeLevel(), item.getNameLevel()));
		}
		return lsItemMstJapan;
	}

}
